package com.example.demo.thread.finals.unsafecar;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 位置信息类
 *
 * @author luowj12
 * @since 2021/6/30 15:25
 */
public class CarLocationTracker {

    private Map<String, Location1> locationMap = new ConcurrentHashMap<>();

    public void updateLocation(String carCode,double x,double y){
        Location1 location = locationMap.get(carCode);
        location.setXY(x,y);
    }

    public Location1 getLocation(String carCode){
        return locationMap.get(carCode);
    }

    public void setLocationMap(String carCode,double x,double y){
        Location1 location = new Location1(x,y);
        locationMap.put(carCode,location);
    }

}
